package com.edu.learning.executors.service;

import com.edu.learning.executors.ThreadDemo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Service;

/**
 * @author ll
 * @Date 2017/11/14 15:05
 */
@Service
public class AsynchronousService {

    @Autowired
    private ApplicationContext applicationContext;

    @Autowired
    private TaskExecutor taskExecutor;

    public void executorAsynchronously() {
        ThreadDemo threadDemo = applicationContext.getBean(ThreadDemo.class);
        taskExecutor.execute(threadDemo);
    }
}
